﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;

namespace JaxDug.Core.Utilities
{
    public class Emailer:IDisposable
    {
        readonly SmtpClient _client;

        public Emailer(SmtpClient client)
        {
            _client = client;
        }
        public void Send(IEnumerable<string> to, string subject, string body)
        {
            var message= new MailMessage();
            foreach(var item in to)
                message.To.Add(item);
            message.Subject=subject;
            message.Body=body;
            _client.Send(message);
        }
        public void Send(string to, string subject, string body)
        {
            var message = new MailMessage();
            
                message.To.Add(to);
            message.Subject = subject;
            message.Body = body;
            _client.Send(message);
        }
        #region IDisposable Members

        public void Dispose()
        {
            _client.Dispose();
        }

        #endregion
    }
}
